//
//  CASchoolView.m
//  LNH
//
//  Created by twentylx on 2018/2/7.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CASchoolView.h"

@implementation CASchoolView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor whiteColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.headerView];
    [self.headerView addSubview:self.leftLineView];
    [self.headerView addSubview:self.titleLabel];
    [self.headerView addSubview:self.rightLineView];
    [self addSubview:self.sjtjBtn];
    [self addSubview:self.xsbdBtn];
    [self addSubview:self.dkjtBtn];
    [self addSubview:self.mjxBtn];
    
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self);
        make.height.mas_equalTo(25);
    }];
    
    [_leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headerView);
        make.right.equalTo(self.titleLabel.mas_left).offset(-10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(1);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.headerView);
        make.width.mas_equalTo(80);
    }];
    
    [_rightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headerView);
        make.left.equalTo(self.titleLabel.mas_right).offset(10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(1);
    }];
    
    [_sjtjBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self);
        make.top.equalTo(self.headerView.mas_bottom).offset(25);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4));
    }];
    
    [_xsbdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.sjtjBtn.mas_right);
        make.top.equalTo(self.headerView.mas_bottom).offset(25);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4));
    }];
    
    [_dkjtBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.xsbdBtn.mas_right);
        make.top.equalTo(self.headerView.mas_bottom).offset(25);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4));
    }];
    
    [_mjxBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dkjtBtn.mas_right);
        make.top.equalTo(self.headerView.mas_bottom).offset(25);
        make.width.mas_equalTo(@(SCREEN_WIDTH/4));
    }];
}

#pragma mark get & set
- (UIView *)headerView {
    if (!_headerView) {
        _headerView = [UIView new];
        _headerView.backgroundColor = RGBCOLOR(233, 85, 19);
    }
    return _headerView;
}

- (UIView *)leftLineView {
    if (!_leftLineView) {
        _leftLineView = [UIView new];
        _leftLineView.backgroundColor = RGBCOLOR(245, 174, 143);
    }
    return _leftLineView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"商学院";
        _titleLabel.font = [UIFont systemFontOfSize:18];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor whiteColor];
    }
    return _titleLabel;
}

- (UIView *)rightLineView {
    if (!_rightLineView) {
        _rightLineView = [UIView new];
        _rightLineView.backgroundColor = RGBCOLOR(245, 174, 143);
    }
    return _rightLineView;
}

-(UIButton *)sjtjBtn
{
    if (!_sjtjBtn) {
        _sjtjBtn = [UIButton new];
        [_sjtjBtn setTitle:@"数据统计" forState:UIControlStateNormal];
        [_sjtjBtn setTitleColor:RGBCOLOR(62, 58, 57) forState:UIControlStateNormal];
        _sjtjBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_sjtjBtn setImage:[UIImage imageNamed:@"sjtj"] forState:UIControlStateNormal];
        _sjtjBtn.imageEdgeInsets = UIEdgeInsetsMake(-20, 25, 0,0);
        _sjtjBtn.titleEdgeInsets = UIEdgeInsetsMake(50, -25, 0, 0);
    }
    return _sjtjBtn;
}

-(UIButton *)xsbdBtn
{
    if (!_xsbdBtn) {
        _xsbdBtn = [UIButton new];
        [_xsbdBtn setTitle:@"新手宝典" forState:UIControlStateNormal];
        [_xsbdBtn setTitleColor:RGBCOLOR(62, 58, 57) forState:UIControlStateNormal];
        _xsbdBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_xsbdBtn setImage:[UIImage imageNamed:@"xsbd"] forState:UIControlStateNormal];
        _xsbdBtn.imageEdgeInsets = UIEdgeInsetsMake(-20, 25, 0,0);
        _xsbdBtn.titleEdgeInsets = UIEdgeInsetsMake(50, -25, 0, 0);
    }
    return _xsbdBtn;
}

-(UIButton *)dkjtBtn
{
    if (!_dkjtBtn) {
        _dkjtBtn = [UIButton new];
        [_dkjtBtn setTitle:@"大咖讲堂" forState:UIControlStateNormal];
        [_dkjtBtn setTitleColor:RGBCOLOR(62, 58, 57) forState:UIControlStateNormal];
        _dkjtBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_dkjtBtn setImage:[UIImage imageNamed:@"dkjt"] forState:UIControlStateNormal];
        _dkjtBtn.imageEdgeInsets = UIEdgeInsetsMake(-20, 30, 0,0);
        _dkjtBtn.titleEdgeInsets = UIEdgeInsetsMake(50, -25, 0, 0);
    }
    return _dkjtBtn;
}

-(UIButton *)mjxBtn
{
    if (!_mjxBtn) {
        _mjxBtn = [UIButton new];
        [_mjxBtn setTitle:@"买家秀" forState:UIControlStateNormal];
        [_mjxBtn setTitleColor:RGBCOLOR(62, 58, 57) forState:UIControlStateNormal];
        _mjxBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_mjxBtn setImage:[UIImage imageNamed:@"mjx"] forState:UIControlStateNormal];
        _mjxBtn.imageEdgeInsets = UIEdgeInsetsMake(-20, 28, 0, 0);
        _mjxBtn.titleEdgeInsets = UIEdgeInsetsMake(50, -25, 0, 0);
    }
    return _mjxBtn;
}

@end
